<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            width: 200px;
            height: 100px;
            background-color: blue;
            position: relative;
        }

        .box1 {
            width: 50px;
            height: 25px;
            text-align: center;
            /* background-color: pink; */
            position: absolute;
            top: 0;
            right: 0;
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="box1"><button>关闭</button></div>
    </div>
    <script>
        const btn = document.querySelector('button')
        const box = document.querySelector('.box')
        btn.addEventListener('click', function () {
            box.style.display = 'none'
        })

    </script>
</body>

</html>